#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
. /etc/functions.sh
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+failsafe() {
+ lock /tmp/.failsafe
+
+ echo "0 1 2 3 4 5u*" > /proc/switch/eth0/vlan/0/ports
+
+ set_state failsafe
+ [ -x "/usr/sbin/nvram" ] && {
+ [ "$(nvram get boot_wait)" != "on" ] && {
+ nvram set boot_wait=on
+ nvram commit
+ }
+ }
+
+ netmsg 192.168.1.255 "Entering Failsafe!"
+ telnetd -l /bin/login <> /dev/null 2>&1
+
+ ash --login
+}
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
mount none /proc -t proc
size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
mount none /tmp -t tmpfs -o size=$size
insmod diag
-echo /sbin/hotplug.failsafe > /proc/sys/kernel/hotplug
set_state preinit
+trap 'FAILSAFE=true' USR1
+echo '/sbin/hotplug.failsafe' > /proc/sys/kernel/hotplug
ifname=eth0
-# WAP54G, WL-HDD
-[ "$(nvram get boardnum)" = "2" \
--o \( "$(nvram get boardnum)" = "asusX" \
- -a "$(($(nvram get et1phyaddr)))" -eq 1 \) ] && ifname="eth1"
+
+# hardware specific overrides
+case "$(cat /proc/diag/model)" in
+ "Linksys WAP54G V1") ifname=eth1;;
+ "ASUS WL-HDD") ifname=eth1;;
+ "ASUS WL-300g") ifname=eth1;;
+ "ASUS (unknown, BCM4702)") ifname=eth1;;
+esac
insmod switch-core
insmod switch-robo || insmod switch-adm || rmmod switch-core
sleep 2
+eval ${FAILSAFE:+failsafe}
+
lock -w /tmp/.failsafe
+set_state preinit
echo /sbin/hotplug > /proc/sys/kernel/hotplug
ifconfig $ifname 0.0.0.0 down
}
mount_root
-
exec /sbin/init
#!/bin/sh
-[ "$1" = "button" -a "$ACTION" = "pressed" ] && {
- echo /bin/true > /proc/sys/kernel/hotplug
- lock /tmp/.failsafe
-
- case "$(nvram get boardtype)" in
- 0x0467|0x042f) echo "0 1 2 3 5u*";;
- *) echo "1 2 3 4 5u*";;
- esac > /proc/switch/eth0/vlan/0/ports
-
- . /etc/functions.sh
- set_state failsafe
- [ "$(nvram get boot_wait)" != "on" ] && {
- nvram set boot_wait=on
- nvram commit
- }
-
- netmsg 192.168.1.255 "Entering Failsafe!"
- telnetd -l /bin/login <> /dev/null 2>&1
-
- exec </dev/console >/dev/console 2>/dev/console
- ash --login
- lock -u /tmp/.failsafe
-}
+case "$1" in
+ button) kill -USR1 1;;
+esac